#!/bin/bash


# 初始化变量
odd=false

while [ "$odd" = false ]; do
  # 提示用户输入一个奇数
  read -p "请输入一个奇数: " num

  # 检查输入是否为奇数
  if (( num % 2 == 0 )); then
    echo "输入的不是奇数，请重新输入！"
  else
    odd=true
  fi
done


# 上半部分
for (( i = 1; i <= num; i += 2 )); do
  # 打印空格
  for (( j = (num - i) / 2; j > 0; j-- )); do
    echo -n " "
  done
  # 打印星号
  for (( k = 1; k <= i; k++ )); do
    echo -n "*"
  done
  echo
done

# 下半部分
for (( i = num - 2; i >= 1; i -= 2 )); do
  # 打印空格
  for (( j = (num - i) / 2; j > 0; j-- )); do
    echo -n " "
  done
  # 打印星号
  for (( k = 1; k <= i; k++ )); do
    echo -n "*"
  done
  echo
done